package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class reflectDemo5 {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException {
//        Class cla=Class.forName("reflect.Person");
//        Object o=cla.newInstance();
//        Method method=cla.getMethod("say",String.class);
//        method.invoke(o,"嘿嘿");


        Class cla=Class.forName("reflect.Person");
        Object o=cla.newInstance();
        Method method=cla.getMethod("say",String.class,int.class);
        method.invoke(o,"嘿嘿",5);
    }
}
